{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import os\n",
    "from pandas import set_option\n",
    "set_option(\"display.max_rows\", 15)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Setting TXT File data location (设定TXT文件位置)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# data_path = 'data/NewDataUnProcess/data0417/train/'\n",
    "data_path = 'data/NewDataUnProcess/'\n",
    "filename = 'YX58-DTXX.txt'\n",
    "# filename = 'BZ102.txt'\n",
    "txt_logs_file = os.path.join(data_path,filename)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n",
     "is_executing": true
    }
   },
   "outputs": [],
   "source": [
    "log_data_begin_row = 0\n",
    "a_L = filename.split(\".\")[0][-2:]\n",
    "if a_L == '录井':\n",
    "    log_data_begin_row = 0\n",
    "    print(\"1\")\n",
    "elif a_L == '常规':\n",
    "    log_data_begin_row = 6\n",
    "    print(\"2\")\n",
    "else:\n",
    "    print(\"3\")\n",
    "    log_data_begin_row = 5"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Loading data with pandas (读取数据)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# un_process = pd.read_csv(txt_logs_file,engine='python',encoding='GBK',header = None, sep = '\\000\\r\\t\\n\\tab ')\n",
    "# default log_data_begin_row = 6\n",
    "un_process = pd.read_csv(txt_logs_file,engine='python',encoding='GBK',header = log_data_begin_row, sep = '\\t\\000')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "usual_log_names = [\"DT\",\"CNL\",\"DEN\",\"GR\",\"RD\",\"RS\",\"DTXX\"]\n",
    "# usual_log_names = [\"DTC_CIFLOG\",\"DTS_CIFLOG\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 3518 entries, 0 to 3517\n",
      "Data columns (total 1 columns):\n",
      "#DEPTH       DTC_CIFLOG   DTS_CIFLOG    3518 non-null object\n",
      "dtypes: object(1)\n",
      "memory usage: 27.6+ KB\n"
     ]
    }
   ],
   "source": [
    "un_process.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>#DEPTH       DTC_CIFLOG   DTS_CIFLOG</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5563.8877    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5564.0401    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5564.1925    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5564.3449    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5564.4973    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5564.6497    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>5564.8021    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3511</th>\n",
       "      <td>6098.9641    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3512</th>\n",
       "      <td>6099.1165    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3513</th>\n",
       "      <td>6099.2689    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3514</th>\n",
       "      <td>6099.4213    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3515</th>\n",
       "      <td>6099.5737    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3516</th>\n",
       "      <td>6099.7261    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3517</th>\n",
       "      <td>6099.8785    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3518 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       #DEPTH       DTC_CIFLOG   DTS_CIFLOG\n",
       "0     5563.8877    -99999.0000  -99999.0000\n",
       "1     5564.0401    -99999.0000  -99999.0000\n",
       "2     5564.1925    -99999.0000  -99999.0000\n",
       "3     5564.3449    -99999.0000  -99999.0000\n",
       "4     5564.4973    -99999.0000  -99999.0000\n",
       "5     5564.6497    -99999.0000  -99999.0000\n",
       "6     5564.8021    -99999.0000  -99999.0000\n",
       "...                                     ...\n",
       "3511  6098.9641    -99999.0000  -99999.0000\n",
       "3512  6099.1165    -99999.0000  -99999.0000\n",
       "3513  6099.2689    -99999.0000  -99999.0000\n",
       "3514  6099.4213    -99999.0000  -99999.0000\n",
       "3515  6099.5737    -99999.0000  -99999.0000\n",
       "3516  6099.7261    -99999.0000  -99999.0000\n",
       "3517  6099.8785    -99999.0000  -99999.0000\n",
       "\n",
       "[3518 rows x 1 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# a = un_process.iloc[7].strip('\\t').tolist()\n",
    "un_process"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# default False | True,根据给定的数据分布，一般i情况下不减少原始分辨率\n",
    "use_custom_resolution = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "traget_log_names = usual_log_names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "if use_custom_resolution:\n",
    "    custom_resolution = 0.5\n",
    "else:\n",
    "    custom_resolution = 1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Remove missing value columns at the end (去除末尾缺失值列)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "process = un_process.dropna(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>#DEPTH       DTC_CIFLOG   DTS_CIFLOG</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5563.8877    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5564.0401    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5564.1925    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5564.3449    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5564.4973    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5564.6497    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>5564.8021    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3511</th>\n",
       "      <td>6098.9641    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3512</th>\n",
       "      <td>6099.1165    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3513</th>\n",
       "      <td>6099.2689    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3514</th>\n",
       "      <td>6099.4213    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3515</th>\n",
       "      <td>6099.5737    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3516</th>\n",
       "      <td>6099.7261    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3517</th>\n",
       "      <td>6099.8785    -99999.0000  -99999.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3518 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       #DEPTH       DTC_CIFLOG   DTS_CIFLOG\n",
       "0     5563.8877    -99999.0000  -99999.0000\n",
       "1     5564.0401    -99999.0000  -99999.0000\n",
       "2     5564.1925    -99999.0000  -99999.0000\n",
       "3     5564.3449    -99999.0000  -99999.0000\n",
       "4     5564.4973    -99999.0000  -99999.0000\n",
       "5     5564.6497    -99999.0000  -99999.0000\n",
       "6     5564.8021    -99999.0000  -99999.0000\n",
       "...                                     ...\n",
       "3511  6098.9641    -99999.0000  -99999.0000\n",
       "3512  6099.1165    -99999.0000  -99999.0000\n",
       "3513  6099.2689    -99999.0000  -99999.0000\n",
       "3514  6099.4213    -99999.0000  -99999.0000\n",
       "3515  6099.5737    -99999.0000  -99999.0000\n",
       "3516  6099.7261    -99999.0000  -99999.0000\n",
       "3517  6099.8785    -99999.0000  -99999.0000\n",
       "\n",
       "[3518 rows x 1 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "process"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Remake column names (重新制作列名称)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "process_cols = process.columns.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "scrolled": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['#DEPTH       DTC_CIFLOG   DTS_CIFLOG']"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "process_cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# 设定曲线同义词\n",
    "synonyms_names = {'CNC':'CNL','TNPH':'CNL','NPHI':'CNL', \n",
    "                  'KTH_P':'GR', 'HSGR':'GR',\n",
    "                  'RHOB':'DEN','RHO1':'DEN','ZDEN':'DEN','RHOZ':'DEN',\n",
    "                  #'DT':'AC',\n",
    "                 'DTC':'DT',\n",
    "                 'RT':'RD','AT90':'RD','RLA5':'RD','LLD':'RD',\n",
    "                 'RXO':'RS','RLA2':'RS','AT20':'RS','LLS':'RS'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "syn_names = list(synonyms_names.keys())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['#DEPTH       DTC_CIFLOG   DTS_CIFLOG']\n"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['#DEPTH', 'DTC_CIFLOG', 'DTS_CIFLOG']\n",
      "1\n",
      "['DTC_CIFLOG', 'DTS_CIFLOG']\n"
     ]
    }
   ],
   "source": [
    "# 把第一个字母转化为大写字母，其余小写\n",
    "cols = []\n",
    "if len(process_cols) == 1:\n",
    "    print(str(process_cols[0]).split())\n",
    "    print(1)\n",
    "    a_list = str(process_cols[0]).split()\n",
    "    for i in range(1,len(a_list)):\n",
    "        a = a_list[i].replace(\" \", \"\")\n",
    "        cols.append(a)\n",
    "    # print(type(a))\n",
    "else:\n",
    "    for i in range(1,len(process_cols)):\n",
    "        a = process_cols[i].split(\" \")[0]\n",
    "        cols.append(a)\n",
    "\n",
    "# 普通测井曲线时候，要注意同义词的替换\n",
    "for i in range(len(cols)):\n",
    "    if cols[i] in syn_names:\n",
    "        cols[i] = synonyms_names[cols[i]]\n",
    "\n",
    "print(cols)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Determine if the new column name on the curve matches the data model target\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "判断曲线新列名是否与目标一致"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": true
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['DTC_CIFLOG', 'DTS_CIFLOG']"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "traget_log_names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "corresponding!!!\n"
     ]
    }
   ],
   "source": [
    "if set(traget_log_names).issubset(set(cols)):\n",
    "    print(\"corresponding!!!\")\n",
    "else:\n",
    "    print(\"logs columns is incompatible!!!\")\n",
    "    missing_logs = [i for i in traget_log_names if (i not in cols)]\n",
    "    print('missing_logs:',missing_logs)\n",
    "#     exit()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Replace the original column name with a new column name(新列名替代原来的列名)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(pandas.core.frame.DataFrame,\n",
       " '#DEPTH       DTC_CIFLOG   DTS_CIFLOG',\n",
       " ['#DEPTH       DTC_CIFLOG   DTS_CIFLOG'])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(process[process_cols]),str(process_cols[0]),process_cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Data splitting(数据分列)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "scrolled": true,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "if len(process_cols) == 1:\n",
    "    process_new = process[str(process_cols[0])].str.split(expand = True)\n",
    "else:\n",
    "    process_new = process.copy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=3, step=1)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "process_new.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "cols.insert(0,\"DEPTH\")\n",
    "process_new.columns = cols"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DEPTH</th>\n",
       "      <th>DTC_CIFLOG</th>\n",
       "      <th>DTS_CIFLOG</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5563.8877</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5564.0401</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5564.1925</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5564.3449</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5564.4973</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5564.6497</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>5564.8021</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3511</th>\n",
       "      <td>6098.9641</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3512</th>\n",
       "      <td>6099.1165</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3513</th>\n",
       "      <td>6099.2689</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3514</th>\n",
       "      <td>6099.4213</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3515</th>\n",
       "      <td>6099.5737</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3516</th>\n",
       "      <td>6099.7261</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3517</th>\n",
       "      <td>6099.8785</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3518 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          DEPTH   DTC_CIFLOG   DTS_CIFLOG\n",
       "0     5563.8877  -99999.0000  -99999.0000\n",
       "1     5564.0401  -99999.0000  -99999.0000\n",
       "2     5564.1925  -99999.0000  -99999.0000\n",
       "3     5564.3449  -99999.0000  -99999.0000\n",
       "4     5564.4973  -99999.0000  -99999.0000\n",
       "5     5564.6497  -99999.0000  -99999.0000\n",
       "6     5564.8021  -99999.0000  -99999.0000\n",
       "...         ...          ...          ...\n",
       "3511  6098.9641  -99999.0000  -99999.0000\n",
       "3512  6099.1165  -99999.0000  -99999.0000\n",
       "3513  6099.2689  -99999.0000  -99999.0000\n",
       "3514  6099.4213  -99999.0000  -99999.0000\n",
       "3515  6099.5737  -99999.0000  -99999.0000\n",
       "3516  6099.7261  -99999.0000  -99999.0000\n",
       "3517  6099.8785  -99999.0000  -99999.0000\n",
       "\n",
       "[3518 rows x 3 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "process_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "new_columns = traget_log_names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['DTC_CIFLOG', 'DTS_CIFLOG']"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['DEPTH', 'DTC_CIFLOG', 'DTS_CIFLOG']"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# C_element.to_csv(data_path + csvfile_name + '_new_'+  '.csv',mode='w',index = False,header=True)\n",
    "new_columns.insert(0,\"DEPTH\")\n",
    "new_columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "log_data = process_new.loc[:,new_columns]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "scrolled": false,
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DEPTH</th>\n",
       "      <th>DTC_CIFLOG</th>\n",
       "      <th>DTS_CIFLOG</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5563.8877</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5564.0401</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5564.1925</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5564.3449</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5564.4973</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5564.6497</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>5564.8021</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3511</th>\n",
       "      <td>6098.9641</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3512</th>\n",
       "      <td>6099.1165</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3513</th>\n",
       "      <td>6099.2689</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3514</th>\n",
       "      <td>6099.4213</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3515</th>\n",
       "      <td>6099.5737</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3516</th>\n",
       "      <td>6099.7261</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3517</th>\n",
       "      <td>6099.8785</td>\n",
       "      <td>-99999.0000</td>\n",
       "      <td>-99999.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3518 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          DEPTH   DTC_CIFLOG   DTS_CIFLOG\n",
       "0     5563.8877  -99999.0000  -99999.0000\n",
       "1     5564.0401  -99999.0000  -99999.0000\n",
       "2     5564.1925  -99999.0000  -99999.0000\n",
       "3     5564.3449  -99999.0000  -99999.0000\n",
       "4     5564.4973  -99999.0000  -99999.0000\n",
       "5     5564.6497  -99999.0000  -99999.0000\n",
       "6     5564.8021  -99999.0000  -99999.0000\n",
       "...         ...          ...          ...\n",
       "3511  6098.9641  -99999.0000  -99999.0000\n",
       "3512  6099.1165  -99999.0000  -99999.0000\n",
       "3513  6099.2689  -99999.0000  -99999.0000\n",
       "3514  6099.4213  -99999.0000  -99999.0000\n",
       "3515  6099.5737  -99999.0000  -99999.0000\n",
       "3516  6099.7261  -99999.0000  -99999.0000\n",
       "3517  6099.8785  -99999.0000  -99999.0000\n",
       "\n",
       "[3518 rows x 3 columns]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "log_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# Obtain logging log attribute information (获取测井日志属性信息)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "if  a_L == '录井':\n",
    "    well_name = filename.split(\"录井\")[0]\n",
    "    orgin_resolution = custom_resolution\n",
    "else:\n",
    "    well_log_info = pd.read_csv(txt_logs_file,engine='python',encoding='GBK',header = None, \n",
    "                                sep = '\\t', nrows = 7)\n",
    "    well_name = well_log_info.iloc[0].to_string().split()[-1]\n",
    "    orgin_resolution = well_log_info.iloc[3].to_string().split()[-1]\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "# well_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "save_data_path =  'data/usual_logs/'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "log_data.to_csv(save_data_path + well_name + '_R_' + str(orgin_resolution) + 'm.csv',mode='w',index = False,header=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Finished!!\n"
     ]
    }
   ],
   "source": [
    "print(\"Finished!!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n",
     "is_executing": true
    }
   },
   "outputs": [],
   "source": [
    "print(save_data_path + well_name + '_R_' + str(orgin_resolution) + 'm.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "256px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}